﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Kinect;

namespace fingerWinForm.GUI
{
    public partial class kinectMotorTilt : Form
    {
        private KinectSensor kinectSensor;
        public kinectMotorTilt(KinectSensor kinect)
        {
            InitializeComponent();
            kinectSensor = kinect;
        }

        private void trackBar_Scroll(object sender, EventArgs e)
        {
            angleLabel.Text = trackBar.Value.ToString();
            
        }

        private void setAngleButton_Click(object sender, EventArgs e)
        {
            try
            {
                kinectSensor.ElevationAngle = trackBar.Value;
            }
            catch (Exception)
            {
                MessageBox.Show(
                    "Kinect is not started.\nChanging the Kinect motor tilt angle is possible only when Kinect is working.",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                this.Close();
                return;
            }
            
        }
    }
}
